package demo05;

import java.util.ArrayList;

/*
 * 题目：自定义4个学生对象,添加到集合,并遍历输出。
 */
public class Demo02ArrayListStudent {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>(); // 存储Student对象的集合
        list.add(new Student("小玉", 22));
        list.add(new Student("小丸子", 20));
        list.add(new Student("锁锁", 26));
        list.add(new Student("大脸猫", 25));
        for (int i = 0; i < list.size(); i++) {
            System.out.println("姓名：" + list.get(i).getName() + "，年龄：" + list.get(i).getAge());
        }
    }
}
